package com.shuorikeji.huohuo.ui.me;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.shuorikeji.huohuo.R;
import com.shuorikeji.huohuo.base.BasePresenterActivity;
import com.shuorikeji.huohuo.bean.UserInfoBean;
import com.shuorikeji.huohuo.bean.UserInfoMainBean;
import com.shuorikeji.huohuo.callback.ClickCallBack;
import com.shuorikeji.huohuo.mvp.AllPresenter;
import com.shuorikeji.huohuo.utils.BusinessUtils;
import com.shuorikeji.huohuo.utils.ToastShowUtil;

import butterknife.BindView;

public class TgHbActivity extends BasePresenterActivity<AllPresenter> {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_ewm)
    ImageView ivEwm;
    @BindView(R.id.tv_tgm)
    TextView tvTgm;

    private UserInfoBean userInfoBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getmImmersionBar().reset().statusBarColor(R.color.transparent).statusBarDarkFont(true, 0.2f).init();
    }

    @Override
    protected void setContentView() {
        setContentView(R.layout.activity_tg_hb);
    }

    @Override
    protected void initData() {
        getUserInfoData();
        ivBack.setOnClickListener(view -> {
            finish();
        });
    }

    private void getUserInfoData() {
        mPresenter.getUserInfo(true, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        UserInfoMainBean data = (UserInfoMainBean) object;
                        userInfoBean = data.getData();
                        tvTgm.setText("我的推广码：" + userInfoBean.getInvite());
                        ivEwm.setImageBitmap(BusinessUtils.getQRCode("https://app.hctonghui.com/h5/#/?invite=" + userInfoBean.getInvite(), 200, 200));
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(TgHbActivity.this, msg);
                        break;
                }
            }
        });
    }
}